home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Essentials / Technical.Notes / ATLK / TN.ATLK.007 < prev    next >
Encoding:
Text File  |  1989-11-08  |  4.9 KB  |  126 lines  |  [TEXT/pdos]

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6.  
  7. AppleTalk
  8. #7:    MLIACTV Flag and the IIe Workstation Card
  9.  
  10. Written by:    Mark Day & Dan Strnad                            November 1989
  11.  
  12. This Technical Note describes a problem using the MLIACTV flag with the IIe 
  13. Workstation Card.
  14. _____________________________________________________________________________
  15.  
  16. When using the Apple IIe Workstation Card, the MLIACTV flag does not always 
  17. show that the MLI (or PFI) is active.  This inconsistency can cause programs 
  18. that use the MLIACTV flag to fail when making MLI calls from interrupt 
  19. routines.  Programs can correct for this problem by making all MLI calls 
  20. through the NewMLI routine listed in this Note and checking the NewMLIActv 
  21. flag instead of the MLIACTV flag.  This approach solves the problem only if 
  22. all MLI calls, including those made by any interrupt routines, are made 
  23. through this routine.
  24.  
  25. The following routine is a replacement for the MLI entry point at $BF00.  
  26. Programs using this routine can perform a JSR to NewMLI instead, which fixes 
  27. the problem.  Section 6.2.1 of the ProDOS 8 Technical Reference Manual details 
  28. how programs can cause the MLI to return the their routine rather than the 
  29. routine that originally called it.  For programs using this technique that are 
  30. also using the routine below, the location below labeled NewCmdAddr replaces 
  31. CmdAdr ($BF9C).  The steps involved in patching the MLI return location still 
  32. apply, as specified in Section 6.2.1 of the ProDOS 8 Technical Reference.
  33.  
  34. ; MLI patch for Apple II Workstation Card
  35. ; by Mark Day
  36. ;
  37. ; code shown is compatible with MPW IIGS cross-assembler
  38. ;
  39. ; Your program should use the NewMLIActv flag instead of
  40. ; MLIACTV ($BF9B), and should JSR NewMLI instead of
  41. ; JSR MLI ($BF00).
  42. ;
  43.  
  44.            machine M6502            ; 6502 code for //e
  45.            longa  off
  46.            longi  off
  47.         
  48. parmptr    equ    0                 ; two bytes on zero page
  49. MLI        equ    $BF00             ; entry to the real MLI
  50.  
  51. NewMLI     proc
  52.  
  53.            php                      ; save old interrupt status to
  54.            pla                      ; temporarily disable interrupts
  55.            sta    oldp              ; so that NewCmdAddr is always valid
  56.            sei                      ; when an interrupting routine sees
  57.                                     ; NewMLI active.
  58.  
  59.            sec
  60.            ror    NewMLIActv        ; NewMLI is now active!
  61.  
  62. ;
  63. ; We need to get the return address from the stack so we can
  64. ; get the command number and parameter block address which
  65. ; follow the JSR NewMLI, and so we can save NewCmdAddr.
  66. ;
  67.            clc
  68.            pla                      ; get low byte of parm address - 1
  69.            sta    parmptr
  70.            adc    #4                ; get real return address
  71.            sta    NewCmdAddr
  72.            pla
  73.            sta    parmptr+1         ; save high byte of parm address - 1
  74.            adc    #0
  75.            sta    NewCmdAddr+1      ; save real return address
  76.  
  77.            lda    oldp
  78.            pha
  79.            plp                      ; reinstate old interrupt status
  80. ;
  81. ; Now, we copy the call number and parameter list pointer that followed
  82. ; the JSR NewMLI, and copy them after a JSR to the real MLI.
  83. ;
  84.            tya                      ; save Y on stack
  85.            pha
  86.            ldy    #1                ; offset to command number
  87.            lda    (parmptr),y       ; get command number
  88.            sta    NewCmdNum
  89.            iny                      ; point to parm list ptr (low)
  90.            lda    (parmptr),y
  91.            sta    NewParmPtr
  92.            iny
  93.            lda    (parmptr),y
  94.            sta    NewParmPtr+1
  95.            pla                      ; unstack value of y register
  96.            tay
  97.  
  98. ;
  99. ; Now, call the real MLI with the user's command and parameter list
  100. ; and jump back to our caller.
  101. ;
  102.            jsr    MLI               ; call the real MLI
  103. NewCmdNum  dc.b   0                 ; command number
  104. NewParmPtr dc.w   0                 ; parameter list pointer
  105.  
  106.            php                      ; save C because LSR changes it!
  107.            lsr    NewMLIActv        ; MLI is no longer active
  108.            plp                      ; restore C
  109.            dc.b   $4C               ; JMP absolute instruction
  110. NewCmdAddr dc.w   0                 ; target of jump, caller's return address
  111.  
  112. NewMLIActv dc.b   0                 ; $80 bit set if MLI active
  113. oldp       ds.b   1                 ; used to preserve processor status
  114.  
  115.            endp
  116.            end
  117.  
  118. Note that this routine also works on the Apple IIGS, even though the problem 
  119. with the MLIACTV flag only affects Apple IIe Workstation Cards.
  120.  
  121.  
  122. Further Reference
  123. _____________________________________________________________________________
  124.     o    AppleShare Programmer's Guide for the Apple IIGS
  125.     o    ProDOS 8 Technical Reference Manual
  126.